<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap core CSS -->
<link rel="stylesheet" type="text/css" href="../../bootstrap-3.3.7/dist/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="../../bootstrap-3.3.7/dist/css/bootstrap-theme.min.css" />
<link rel="stylesheet" type="text/css" href="../../css/index.css" />
<link rel="stylesheet" type="text/css" href="../../css/personal.css" />
<link rel="stylesheet" type="text/css" href="../../css/background.css" />
<link rel="stylesheet" type="text/css" href="../../css/bootstrapValidator.min.css" />
<script type="text/javascript" src="../../bootstrap-3.3.7/dist/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap-3.3.7/dist/js/bootstrap.js"></script>
<script type="text/javascript" src="../../js/bootstrapValidator.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="../../bootstrap-3.3.7/docs/assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<link rel="stylesheet" href="../../zTree/css/metroStyle/metroStyle.css" type="text/css">
<script type="text/javascript" src="../../js/browser.js"></script>
<script type="text/javascript" src="../../zTree/js/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript" src="../../zTree/js/jquery.ztree.excheck-3.5.js"></script>
<script type="text/javascript" src="../../zTree/js/jquery.ztree.exedit-3.5.js"></script>
<script type="text/javascript">
</script>

</head>
<body>
	<h4 class="heading">知识迁移</h4>
	<div class="myline"></div>
		<div class="row" style="margin-top: 50px;">
			<div class="col-md-4">
				
				<ul id="origintree" class="ztree" style="background-color: #F5FFFA; border: 0px; overflow-y: auto; overflow-x: auto;"></ul>
			</div>
			<div class="col-md-2" style="text-align:center;margin-top:170px;">
				<button type="button" class="btn btn-default" onclick="migrate()" style="float:left">迁移至</button>
			</div>
			<div class="col-md-4">
				<ul id="destinationTree" class="ztree" style="background-color: #F5FFFA; border: 0px; overflow-y: auto; overflow-x: auto;"></ul>
			</div>
		</div>
	
    <script type="text/javascript">
    function migrate(){
    	var origin = $.fn.zTree.getZTreeObj("origintree");
    	var originnodes = origin.getSelectedNodes();
    	var destination = $.fn.zTree.getZTreeObj("destinationTree");
    	var destinationnodes = destination.getSelectedNodes();
    	if(originnodes.length==1&&destinationnodes.length==1){
    		if(!destinationnodes[0].isParent){
    			var info = confirm("您确定将" + originnodes[0].name + "中的知识迁移到"+destinationnodes[0].name+"中吗?");
    			if (info == true){
    				$.ajax({
        				async : false,
        				cache : false,
        				type : 'get',
        				dataType : "json",
        				url : "../information/migrate",
        				data : {
        					"origin":originnodes[0].id,
        					"destination":destinationnodes[0].id
        					},
        				error : function() {
        					alert('迁移失败');
        				},
        				success : function(data) {
        					if(data==1)
        						alert("迁移成功");
        					if(data==0)
        						alert('迁移失败');
        				}
        			});
    			}	
    		}
    		else{
    			alert("迁移目标节点不能包含子库");
    		}
    	}
    	else{
    		alert("节点选择错误");
    	}
    	
    }
    </script>

	<script type="text/javascript">
		var setting_origin = {
			view : {
				showLine : false,
				showIcon : false,
				checkable : true
			},
			edit : {
				enable : true,
				editNameSelectAll : true,
				showRemoveBtn : showRemoveBtn,
				showRenameBtn : showRenameBtn
			},
			data : {
				simpleData : {
					enable : true
				}
			}
		};

		$(document).ready(function() {
			var treeNode = [];
			$.ajax({
				async : false,
				cache : false,
				type : 'POST',
				dataType : "json",
				url : "../configration/getReczsk",
				error : function() {
					alert('请求失败');
				},
				success : function(data) {
					treeNode = data;
				}
			});
			var tree=$.fn.zTree.init($("#origintree"), setting_origin, treeNode);
			tree.expandAll(true);
		});

		function showRemoveBtn(treeId, treeNode) {
			return false;
		}

		function showRenameBtn(treeId, treeNode) {
			return false;
		}
	</script>
	<script type="text/javascript">
		var setting_destination = {
			view : {
				showLine : false,
				showIcon : false,
				checkable : true
			},
			edit : {
				enable : true,
				editNameSelectAll : true,
				showRemoveBtn : showRemoveBtn,
				showRenameBtn : showRenameBtn
			},
			data : {
				simpleData : {
					enable : true
				}
			}
		};

		$(document).ready(
				function() {
					var treeNode = [];
					$.ajax({
						async : false,
						cache : false,
						type : 'POST',
						dataType : "json",
						url : "../configration/getReczsk",
						error : function() {
							alert('请求失败');
						},
						success : function(data) {
							treeNode = data;
						}
					});
					var tree=$.fn.zTree.init($("#destinationTree"), setting_destination,
							treeNode);
					tree.expandAll(true);
				});

		function showRemoveBtn(treeId, treeNode) {
			return false;
		}
		//改过了

		function showRenameBtn(treeId, treeNode) {
			return false;
		}
	</script>
</body>
</html>